<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>

<head>
    <meta charset="utf-8" />
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <jsp:include page="../common/header.jsp"></jsp:include>
    <%@include file="../common/taglib.jsp"%>
    <!-- ================== END BASE CSS STYLE ================== -->
    <style>
        label.control-label.col-md-4.col-sm-4 {
            width: 120px;
        }
        .col-md-6.col-sm-6 {
            width: 300px;
        }
        .col-md-1.control-label{
            width: 142px;
        }
    </style>
    <!-- ================== 单独作用于本页表格td ================== -->
    <style>


    </style>
    <!-- ================== 单独作用于本页表格td ================== -->

</head>
<body>
<!-- begin #page-loader -->
<div id="page-loader" class="fade in"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
    <jsp:include page="../common/top.jsp"/>

    <!-- begin #sidebar -->
    <jsp:include page="../common/sitebar.jsp"/>
    <div class="sidebar-bg"></div>
    <!-- end #sidebar -->

    <!-- begin #content -->
    <div id="content" class="content">
        <div class="row">
            <!-- begin col-12 -->
            <div class="col-md-12">
                <!-- begin panel -->
                <div class="panel panel-inverse">
                    <section class="pad-top-10 pad-bottom-20">
                        <ul id="myTab" class="nav nav-tabs">
                            <%--<li class="active"><a href="javascript:void(0);" onclick="showRead()">待定价产品</a></li>
                            <li><a href="javascript:void(0);" onclick="showAlread()">已定价产品</a></li>--%>
                            <shiro:hasPermission name='product:forPricing'>
                                <li class="active"><a href="<%=path%>/product/toList">待定价产品</a></li>
                            </shiro:hasPermission>
                            <shiro:hasPermission name='product:havePricing'>
                                <li><a href="<%=path%>/product/toList?m=1">已定价产品</a></li>
                            </shiro:hasPermission>
                            <shiro:hasPermission name='product:createProduct'>
                                <li><a href="<%=path%>/product/toCreatePage">新建产品</a></li>
                            </shiro:hasPermission>
                        </ul>
                        <input name="types" id="types" type="hidden" value="${types}">
                        <input name="m1" id="m1" type="hidden" value="${m1}">
                        <input name="role" id="role" type="hidden" value="${role}">
                        <input name="count" id="count" type="hidden" value="${count}">
                        <div class="form-wrap mar-bottom-0">
                            <div class="tab-content">
                                <%--待定价列表--%>
                                <div id="tab1" class="tab-pane fade active in">
                                <section>
                                       <form class="form-inline">
                                           <div class="form-group">
                                               <label>保险公司：</label>
                                               <select class="form-control m-r-20" name="companyId" id="companyId">
                                                   <option value="-1">请选择</option>
                                                   <c:forEach items="${insurerLists}" var="insurer" varStatus="status">
                                                       <option value="${insurer.tid }">${insurer.name }</option>
                                                   </c:forEach>
                                               </select>
                                           </div>
                                           <div class="form-group">
                                               <label>险种：</label>
                                               <select class="form-control m-r-10" name="type" id="type" style="width: 132px;">
                                                   <option value="2">请选择</option>
                                                   <option value="0">交强险</option>
                                                   <option value="1">商业险</option>
                                               </select>
                                           </div>
                                           <button type="button" onclick="search()" class="btn btn-primary">查询</button>
                                       </form>

                                    <table id="modeltable" class="table table-striped table-bordered"
                                           style="word-break:break-all;word-wrap:break-word">
                                        <thead>
                                        <tr>
                                            <th>产品编号</th>
                                            <th>保险公司</th>
                                            <th>险种</th>
                                            <th>合同有效期</th>
                                            <th>价税分离</th>
                                            <th>补点开票形式</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                            <%--<th>编辑</th>
                                            <th>删除</th>--%>
                                        </tr>
                                        </thead>
                                    </table>
                                </section>
                            </div>
                                <%--已定价列表--%>
                                <div id="tab2" class="tab-pane fade">
                                    <section>
                                        <form class="form-inline">
                                            <div class="form-group">
                                                <label>保险公司：</label>
                                                    <select class="form-control m-r-20" name="companyId" id="companyId1">
                                                        <option value="-1">请选择</option>
                                                        <c:forEach items="${insurerLists}" var="insurer" varStatus="status">
                                                            <option value="${insurer.tid }">${insurer.name }</option>
                                                        </c:forEach>
                                                    </select>
                                                <label>险种：</label>
                                                    <select class="form-control m-r-20" name="type" id="type1" style="width: 132px;">
                                                        <option value="2">请选择</option>
                                                        <option value="0">交强险</option>
                                                        <option value="1">商业险</option>
                                                    </select>
                                                <label>状态：</label>
                                                    <select class="form-control m-r-10" name="useStatus" id="useStatus" style="width: 132px;">
                                                        <option value="2">请选择</option>
                                                        <option value="0">已启用</option>
                                                        <option value="1">已禁用</option>
                                                        <option value="3">已过期</option>
                                                    </select>
                                                    <button type="button" onclick="search1()" class="btn btn-primary">查询</button>
                                            </div>
                                        </form>
                                        <table id="modeltable1" class="table table-striped table-bordered"
                                               style="word-break:break-all;word-wrap:break-word">
                                            <thead>
                                            <tr>
                                                <th>产品编号</th>
                                                <th>保险公司</th>
                                                <th>险种</th>
                                                <th>合同有效期</th>
                                                <th>价税分离</th>
                                                <th>补点开票形式</th>
                                                <th>状态</th>
                                                <th>操作</th>
                                                <%--<th>编辑</th>
                                                <th>删除</th>--%>
                                            </tr>
                                            </thead>
                                        </table>
                                    </section>
                                </div>
                                <%--新建产品--%>
                                <div id="tab3" class="tab-pane fade">
                                    <form class="form-horizontal form-bordered" id="myForm4" onsubmit="return false" method="post" data-parsley-validate="true">
                                        <div>
                                        <div class="form-group"><%--action="<%=path%>/product/insert"--%>
                                            <label class="control-label col-md-4 col-sm-4">保险公司：</label>
                                            <div class="col-md-6 col-sm-6">
                                                <input type="hidden" name="company" id="company">
                                                <input type="hidden" name="ts" id="ts">
                                                <select class="form-control" id="select" name="companyId" onchange="changeSalesman()" data-parsley-required="true" data-parsley-required-message="请选择保险公司">
                                                    <option value="">请选择</option>
                                                    <c:forEach items="${insurerList}" var="insurer">
                                                        <option value="${insurer.tid}">${insurer.name}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-4 col-sm-4" for="email">业务员：</label>
                                            <div class="col-md-6 col-sm-6">
                                                <input type="hidden" name="userName" id="userName">
                                                <select class="form-control" id="email" name="userId" data-parsley-required="true" data-parsley-required-message="请选择业务员">
                                                    <option value="">请选择</option>

                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-4 col-sm-4">险种：</label>
                                            <div class="col-md-6 col-sm-6">
                                                <input type="hidden" name="ss" id="ss">
                                                <select class="form-control" id="select-required" name="type" data-parsley-required="true" data-parsley-required-message="请选择险种" data-parsley-unique="true" data-parsley-unique-message="该产品已存在">
                                                    <option value="">请选择</option>
                                                    <option value="0">交强险</option>
                                                    <option value="1">商业险</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-4 col-sm-4" for="datetimepicker">合同有效期：</label>
                                            <div class="col-md-6 col-sm-6">
                                                <input class="form-control" type="text" id="datetimepicker" name="contractTime" data-parsley-required="true" placeholder="yyyy-MM-dd"  data-parsley-required-message="请输入合同有效期"
                                                data-parsley-dateTime="true" data-parsley-dateTime-message="请输入正确的日期格式"/>
                                            </div>
                                        </div>
                                            <div class="form-group">
                                                <label class="control-label col-md-4 col-sm-4" for="datetimepicker">&nbsp;</label>
                                                <div class="col-md-6 col-sm-6">
                                                    <input type="button" onclick="createProduct()" class="btn btn-primary m-r-10" id="sun" value="提交"/>
                                                    <button type="button" onclick="openModel(null,3)" class="btn btn-default">取消</button>
                                                </div>
                                            </div>
                                        </div>

                                    </form>

                                </div>
                                <%--税点设置--%>
                                <div id="tab4" class="tab-pane fade">

                                    <form class="form-horizontal" action="<%=path%>/product/setPoint" method="post" data-parsley-validate="true">
                                        <input type="hidden" name="tid" value="${product1.tid}">
                                        <input type="hidden" name="m" value="${m}">
                                        <div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">保险公司：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product1.company}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">业务员：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product1.userName}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">险种：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product1.type=='0'?'交强险':product1.type=='1'?'商业险':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">合同有效期：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product1.contractTime}</p>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">价税分离：</label>
                                            <div class="col-sm-10" style="margin-left: 20px;">
                                                <%--<p style="font-weight: bold" class="form-control-static">email@example.com</p>--%>
                                                <label class="radio">
                                                    <input type="radio" name="separateStatus" value="1" ${product1.separateStatus=='1'?'checked':''} data-parsley-required="true"  data-parsley-required-message="请选择价税是否分离">是

                                                </label>
                                                <label class="radio">
                                                    <input type="radio" name="separateStatus" value="2" ${product1.separateStatus=='2'?'checked':''}>否
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">补点开票形式：</label>
                                            <div class="col-sm-10" style="margin-left: 20px;">
                                                <label class="radio">
                                                    <input type="radio" name="modalityStatus" value="1" ${product1.modalityStatus=='1'?'checked':''} data-parsley-required="true" data-parsley-required-message="请选择补点开票形式">现金

                                                </label>
                                                <label class="radio">
                                                    <input type="radio" name="modalityStatus" value="2" ${product1.modalityStatus=='2'?'checked':''}>三方开票
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label" for="message">备注：</label>
                                            <div class="col-md-4">
                                                <textarea class="form-control" id="message" name="remark" rows="4" data-parsley-required="true" data-parsley-length="[1, 100]" data-parsley-length-message="请输入100字符以内" placeholder="请输入备注" data-parsley-required-message="请输入备注"></textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">&nbsp;</label>
                                            <div class="col-sm-10">
                                                <button type="submit" class="btn btn-primary m-r-10" onclick="changeStatus(this)">提交</button>
                                                <button type="button" class="btn btn-default" onclick="openModel(null,3)">取消</button>
                                            </div>
                                        </div>

                                    </form>
                                    <table class="bg-warning">
                                        <thead>
                                            <th width="150">操作事项</th>
                                            <th width="200">操作人</th>
                                            <th width="200">操作时间</th>
                                            <th>备注</th>
                                        </thead>
                                        <tbody>
                                            <c:forEach items="${businessLogList1}" var="busunessLog">
                                                    <tr>
                                                        <td>${busunessLog.content}</td>
                                                        <td>${busunessLog.createUser.roleName}(${busunessLog.createUser.realName})</td>
                                                        <td><javatime:format value="${busunessLog.createAt}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                                        <td>${busunessLog.remark}</td>
                                                    </tr>
                                            </c:forEach>
                                        </tbody>
                                    </table>

                                </div>
                                <%--自留点位设置--%>
                                <div id="tab5" class="tab-pane fade">
                                    <div class="form-group hidden" id="add" >
                                        <label class="col-md-1 control-label">垫全保费账期：</label>
                                        <div class="col-md-3" style="width: 150px;">
                                            <div class="input-group">
                                                <input type="text" name="collectionForm[0].paymentDays" class="form-control" placeholder="账期" data-parsley-required="true" data-parsley-required-message="请输入账期" data-parsley-numbers="true" data-parsley-numbers-message="请输入3位以内的整数">
                                                <span class="input-group-addon">天</span>
                                            </div>
                                        </div>
                                        <label class="col-md-1 control-label">垫全保费自留点位：</label>
                                        <div class="col-md-3" style="width: 150px;">
                                            <div class="input-group">
                                                <input type="text" name="collectionForm[0].earnings" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入自留点位">
                                                <span class="input-group-addon">%</span>
                                            </div>
                                        </div>
                                        <div class="col-md-3" style="width: 150px;">
                                            <div class="input-group">
                                                <a class="btn btn-sm btn-cancle" onclick="deleteSeniorManagerDiv(this)"> - 删除</a>
                                            </div>
                                        </div>
                                    </div>
                                    <form class="form-horizontal"  action="<%=path%>/product/setEarningPoint" method="post" data-parsley-validate="true">
                                        <input type="hidden" name="tid" value="${product2.tid}">
                                        <input name="m" type="hidden" value="${m2}">
                                        <div style="border-bottom: 1px dashed #ddd;height: auto;
                                                    margin-bottom: 30px;
                                                    padding-top: 15px;
                                                    padding-bottom: 20px;"
                                        >
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">保险公司：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product2.company}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">业务员：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product2.userName}</p>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-md-1 control-label">险种：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product2.type=='0'?'交强险':product2.type=='1'?'商业险':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">合同有效期：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product2.contractTime.toString()}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">价税分离：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product2.separateStatus=='1'?'是':product2.separateStatus=='2'?'否':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">补点开票形式：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product2.modalityStatus=='1'?'现金':product2.modalityStatus=='2'?'三方开票':'--'}</p>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">不垫资自留点位：</label>
                                            <%--<div class="col-sm-10">
                                                <p style="font-weight: bold" class="form-control-static">email@example.com</p>
                                            </div>--%>
                                            <div class="input-group" style="width: 135px;padding-left: 13px;">
                                                <%--<span class="input-group-addon">$</span>--%>
                                                <c:if test="${product2.earingPointList.size()==0}">
                                                    <div class="input-group">
                                                        <input type="text" name="earning" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入不垫资自留点位">
                                                        <span class="input-group-addon">%</span>
                                                    </div>
                                                </c:if>
                                                <c:if test="${product2.earingPointList.size()!=0}">
                                                    <c:forEach items="${product2.earingPointList}" var="ea">
                                                        <c:if test="${ea.type==1}">
                                                            <div class="input-group">
                                                                <input type="text" name="earning" value="${ea.earnings}" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入不垫资自留点位">
                                                                <span class="input-group-addon">%</span>
                                                            </div>
                                                        </c:if>
                                                    </c:forEach>
                                                </c:if>
                                                <%--<span class="input-group-addon">%</span>--%>
                                            </div>

                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">垫返点自留点位：</label>
                                            <div class="input-group" style="width: 135px;padding-left: 13px;">
                                                <%--<span class="input-group-addon">$</span>--%>
                                                <c:if test="${product2.earingPointList.size()==0}">
                                                    <div class="input-group">
                                                        <input type="text" name="earning1" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入垫返点自留点位">
                                                        <span class="input-group-addon">%</span>
                                                    </div>
                                                </c:if>
                                                <c:if test="${product2.earingPointList.size()!=0}">
                                                    <c:forEach items="${product2.earingPointList}" var="ea">
                                                        <c:if test="${ea.type==1}">
                                                            <div class="input-group">
                                                                <input type="text" name="earning1" value="${ea.earnings}" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入垫返点自留点位">
                                                                <span class="input-group-addon">%</span>
                                                            </div>
                                                        </c:if>
                                                    </c:forEach>
                                                </c:if>

                                                <%--<span class="input-group-addon">%</span>--%>
                                            </div>

                                        </div>
                                        <div>
                                            <div id="appendDiv"></div>
                                            <c:if test="${product2.earingPointList.size()==0}">
                                                <div class="form-group">
                                                    <label class="col-md-1 control-label">垫全保费账期：</label>
                                                    <div class="col-md-3" style="width: 150px;">
                                                        <div class="input-group">
                                                            <input type="text" name="collectionForm[1].paymentDays" class="form-control" placeholder="账期" data-parsley-required="true" data-parsley-required-message="请输入账期" data-parsley-numbers="true" data-parsley-numbers-message="请输入3位以内的整数">
                                                            <span class="input-group-addon">天</span>
                                                        </div>
                                                    </div>
                                                    <label class="col-md-1 control-label">垫全保费自留点位：</label>
                                                    <div class="col-md-3" style="width: 150px;">
                                                        <div class="input-group">
                                                            <input type="text" name="collectionForm[1].earnings" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入自留点位">
                                                            <span class="input-group-addon">%</span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </c:if>
                                            <c:if test="${product2.earingPointList.size()!=0}">
                                                <c:forEach items="${product2.earingPointList}" var="ea" varStatus="status">
                                                    <c:if test="${ea.type==3}">
                                                        <div class="form-group">
                                                            <label class="col-md-1 control-label">${status.index!=2?'&nbsp;':'垫全保费账期：'}</label>
                                                            <div class="col-md-3" style="width: 150px;">
                                                                <div class="input-group">
                                                                    <input type="text" name="collectionForm[${status.index-1}].paymentDays" value="${ea.paymentDays}" class="form-control" placeholder="账期" data-parsley-required="true" data-parsley-required-message="请输入账期" data-parsley-numbers="true" data-parsley-numbers-message="请输入3位以内的整数">
                                                                    <span class="input-group-addon">天</span>
                                                                </div>

                                                            </div>
                                                            <label class="col-md-1 control-label">垫全保费自留点位：</label>
                                                            <div class="col-md-3" style="width: 150px;">
                                                                <div class="input-group">
                                                                    <input type="text" name="collectionForm[${status.index-1}].earnings" value="${ea.earnings}" class="form-control" data-parsley-point="true" data-parsley-point-message="请输入正确的数字格式" data-parsley-required="true" data-parsley-required-message="请输入自留点位">
                                                                    <span class="input-group-addon">%</span>
                                                                </div>
                                                            </div>
                                                            <c:if test="${status.index!=2}">
                                                                <div class="col-md-3" style="width: 150px;">
                                                                    <div class="input-group">
                                                                        <a class="btn btn-sm btn-cancle" onclick="deleteSeniorManagerDiv(this)"> - 删除</a>
                                                                    </div>
                                                                </div>
                                                            </c:if>
                                                        </div>
                                                    </c:if>
                                                </c:forEach>
                                            </c:if>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">&nbsp;</label>
                                            <div class="col-sm-10">
                                                <a href="javascript:void(0);" onclick="addTime()">+添加账期</a>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label" for="message1">备注：</label>
                                            <div class="col-md-4">
                                                <textarea class="form-control" id="message1" name="remark" rows="4" data-parsley-required="true" data-parsley-length="[1, 100]" data-parsley-length-message="请输入100字符以内" placeholder="请输入备注" data-parsley-required-message="请输入备注"></textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label">&nbsp;</label>
                                            <div class="col-sm-10">
                                                <button type="submit" class="btn btn-primary m-r-10" onclick="changeStatus(this)">提交</button>
                                                <button type="button" class="btn btn-default" onclick="openModel(null,3)">取消</button>
                                            </div>
                                        </div>
                                    </form>
                                    <table class="bg-warning">
                                        <thead>
                                            <th width="150">操作事项</th>
                                            <th width="200">操作人</th>
                                            <th width="200">操作时间</th>
                                            <th>备注</th>
                                        </thead>
                                        <tbody>
                                            <c:forEach items="${businessLogList}" var="busunessLog">
                                                <tr>
                                                    <td>${busunessLog.content}</td>
                                                    <td>${busunessLog.createUser.roleName}(${busunessLog.createUser.realName})</td>
                                                    <td><javatime:format value="${busunessLog.createAt}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                                    <td>${busunessLog.remark}</td>
                                                </tr>
                                            </c:forEach>
                                        </tbody>
                                    </table>
                                </div>
                                <%--审核--%>
                                <div id="tab6" class="tab-pane fade">

                                    <form id="myForm7" class="form-horizontal" method="post" onsubmit="return false;" data-parsley-validate="true">
                                        <input type="hidden" name="tid" value="${product3.tid}">
                                        <div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">保险公司：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product3.company}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">业务员：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product3.userName}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">险种：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product3.type=='0'?'交强险':product3.type=='1'?'商业险':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">合同有效期：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product3.contractTime}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">价税分离：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product3.separateStatus=='1'?'是':product3.separateStatus=='2'?'否':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">补点开票形式：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${product3.modalityStatus=='1'?'现金':product3.modalityStatus=='2'?'三方开票':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">不垫资自留点位：</label>
                                                <div class="col-sm-10">
                                                    <c:forEach items="${product3.earingPointList}" var="earing">
                                                        <c:if test="${earing.type==1}">
                                                            <p class="form-control-static">${earing.earnings}%</p>
                                                        </c:if>
                                                    </c:forEach>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">垫返点自留点位：</label>
                                                <div class="col-sm-10">
                                                    <c:forEach items="${product3.earingPointList}" var="earing">
                                                        <c:if test="${earing.type==2}">
                                                            <p class="form-control-static">${earing.earnings}%</p>
                                                        </c:if>
                                                    </c:forEach>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">垫全保费账期：</label>
                                                <div class="col-sm-10">
                                                    <c:forEach items="${product3.earingPointList}" var="earing">
                                                        <c:if test="${earing.type==3}">
                                                            <p class="form-control-static">账期${earing.paymentDays}天&nbsp;
                                                                &nbsp;&nbsp;&nbsp;&nbsp;垫全保费自留点位：${earing.earnings}%
                                                            </p>
                                                        </c:if>
                                                    </c:forEach>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-1 control-label" for="message2">审核意见：</label>
                                            <div class="col-md-4">
                                                <textarea class="form-control" id="message2" name="opinion" rows="4" data-parsley-required="true" data-parsley-length="[1, 100]" data-parsley-length-message="请输入100字符以内" placeholder="请填写审核意见" data-parsley-required-message="请输入备注"></textarea>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-md-1 control-label" for="message2">&nbsp;</label>
                                            <div class="col-md-4">
                                                <button type="button" onclick="openModel1(1)" class="btn btn-primary m-r-10">通过</button>
                                                <button type="button" onclick="openModel1(2)" class="btn btn-default">驳回</button>
                                            </div>
                                        </div>
                                        <%--<button style="width: 115px;height: auto;margin-left: 110px;" type="button" onclick="openModel(null,7)" class="btn btn-primary">通过</button>
                                        <button style="width: 115px;height: auto;margin-left: 30px;" type="button" onclick="openModel(null,5)" class="btn btn-default">驳回</button>--%>
                                    </form>
                                    <table class="bg-warning">
                                        <thead>
                                            <th width="150">操作事项</th>
                                            <th width="200">操作人</th>
                                            <th width="200">操作时间</th>
                                            <th>备注</th>
                                        </thead>
                                        <tbody>
                                        <c:forEach items="${businessLogList2}" var="busunessLog">
                                            <tr>
                                                <td>${busunessLog.content}</td>
                                                <td>${busunessLog.createUser.roleName}(${busunessLog.createUser.realName})</td>
                                                <td><javatime:format value="${busunessLog.createAt}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                                <td>${busunessLog.remark}</td>
                                            </tr>
                                        </c:forEach>
                                        </tbody>
                                    </table>

                                </div>
                                <%--详情--%>
                                <div id="tab7" class="tab-pane fade">

                                    <form class="form-horizontal">
                                        <input type="hidden" name="tid" value="${produ.tid}">
                                        <div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">保险公司：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${produ.company}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">业务员：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${produ.userName}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">险种：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${produ.type=='0'?'交强险':produ.type=='1'?'商业险':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">合同有效期：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${produ.contractTime}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">价税分离：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${produ.separateStatus=='1'?'是':produ.separateStatus=='2'?'否':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">补点开票形式：</label>
                                                <div class="col-sm-10">
                                                    <p class="form-control-static">${produ.modalityStatus=='1'?'现金':produ.modalityStatus=='2'?'三方开票':'--'}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">不垫资自留点位：</label>
                                                <div class="col-sm-10">
                                                    <c:forEach items="${produ.earingPointList}" var="earing">
                                                        <c:if test="${earing.type==1}">
                                                            <p class="form-control-static">${earing.earnings}%</p>
                                                        </c:if>
                                                    </c:forEach>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">垫返点自留点位：</label>
                                                <div class="col-sm-10">
                                                    <c:forEach items="${produ.earingPointList}" var="earing">
                                                        <c:if test="${earing.type==2}">
                                                            <p class="form-control-static">${earing.earnings}%</p>
                                                        </c:if>
                                                    </c:forEach>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-1 control-label">垫全保费账期：</label>
                                                <div class="col-sm-10">
                                                    <c:forEach items="${produ.earingPointList}" var="earing">
                                                        <c:if test="${earing.type==3}">
                                                            <p class="form-control-static">账期${earing.paymentDays}天&nbsp;
                                                                &nbsp;&nbsp;&nbsp;&nbsp;垫全保费自留点位：${earing.earnings}%
                                                            </p>
                                                        </c:if>
                                                    </c:forEach>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                    <table class="bg-warning">
                                        <thead>
                                            <th width="150">操作事项</th>
                                            <th width="200">操作人</th>
                                            <th width="200">操作时间</th>
                                            <th>备注</th>
                                        </thead>
                                        <tbody>
                                        <c:forEach items="${businessLogList3}" var="busunessLog">
                                            <tr>
                                                <td>${busunessLog.content}</td>
                                                <td>${busunessLog.createUser.roleName}(${busunessLog.createUser.realName})</td>
                                                <td><javatime:format value="${busunessLog.createAt}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                                <td>${busunessLog.remark}</td>
                                            </tr>
                                        </c:forEach>
                                        </tbody>
                                    </table>

                                </div>
                                <%--提示框--%>
                                <div class="modal fade" id="modal-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                    <input type="hidden" name="tid" id="tid">
                                    <input type="hidden" name="type" id="typee">
                                    <div class="modal-dialog modal-sm">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                <h4 class="modal-title">温馨提示</h4>
                                            </div>
                                            <div class="modal-body" id="me">

                                            </div>
                                            <div class="modal-footer">
                                                <a href="javascript:;" onclick="doSomeThing()" class="btn btn-sm btn-primary">确定</a>
                                                <a href="javascript:;" class="btn btn-sm btn-default" data-dismiss="modal">取消</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <%--<shiro:hasPermission name="用户管理-新增">
                            <div class="alert-info fade in">
                                <button type="button" class="btn btn-primary m-l-20 m-t-10 m-b-10" onclick="toadd()">新增</button>
                            </div>
                        </shiro:hasPermission>--%>
                    </section>
                </div>
                <!-- end panel -->
            </div>
            <!-- end col-12 -->
        </div>
        <!-- end row -->
    </div>

    <!-- end #content -->

</div>
<!-- end page container -->
<jsp:include page="../common/footer.jsp"/>
<%--<script src="${ctx}/static/js/product/product_list.js"></script>--%>
<script src="${ctx}/static/js/order/order.js"></script>
<!-- ================== END PAGE LEVEL JS ================== -->
<script>
    /*$(document).ready(function () {
     App.init();
     TableManageFixedHeader.init();

     $('.datepicker-default').datepicker({
     language: 'zh-CN',//显示中文
     format: 'yyyy-mm-dd',//显示格式
     minView: "month",//设置只显示到月份
     initialDate: new Date(),//初始化当前日期
     autoclose: true,//选中自动关闭
     todayBtn: 'linked'//显示今日按钮
     });

     });*/
    $(document).ready(function() {

        App.init();
        TableManageFixedHeader.init();
        wrapTable1();
        wrapTable2();
        var m = $("#m1").val();
        if(m!=null){
            if (m=='0'){
                showRead();
            }else if(m == '1'){
                showAlread();
            }
        }
        var types = $("#types").val();
        if (types!=null){
            var n =null;
            var id = '';
            if(types == '2'){
                n = "税点设置";
                id = "tab4";
            }else if(types == '3'){
                n = "自留点位设置";
                id = "tab5";
            }else if(types == '5'){
                n = "产品详情";
                id = "tab7";
            } else if(types == '6'){
                n = "审核";
                id = "tab6";
            }else if(types == '4'){
                $("#myTab li:eq(0)").removeClass("active");
                $("#myTab li:eq(1)").removeClass("active");
                $("#myTab li:eq(3)").removeClass("active");
                $("#myTab li:eq(3)").remove();
                //$('#myTab a:first').tab('hide');
                $("#tab1").removeClass(" active in");
                $("#tab2").removeClass(" active in");
                $("#tab4").removeClass(" active in");
                $("#tab5").removeClass(" active in");
                $("#tab6").removeClass(" active in");
                $("#tab7").removeClass(" active in");
                $("#myTab li:eq(2)").addClass("active");
                $("#tab3").addClass(" active in")
            }
            if(n!=null){
                var ul = document.getElementById("myTab")//定位ul

                var li= document.createElement("li"); //创建li
                var href_a = document.createElement("a"); //创建li中的链接a
                href_a.href="javascript:void(0)"; //连接地址或执行函数
                href_a.innerHTML =n; //链接显示文本（相当于标签标题）
                //li.innerHTML=""; //标签页的标题
                li.id="d1"; //标签页ID

                li.appendChild(href_a);//将a添加到li
                ul.appendChild(li); //将li添加到ul

                //$('#myTab a:first').tab('hide');
                $("#myTab li:eq(3)").addClass("active");
                $("#myTab li:eq(0)").removeClass("active");
                $("#myTab li:eq(1)").removeClass("active");
                $("#tab1").removeClass(" active in");
                $("#tab2").removeClass(" active in");
                $("#"+id).addClass(" active in");
                $("#types").val(null);
            }

        }

        var count = $("#count").val();
        var storage=window.localStorage;
        if(count!=0){
            var i = storage.setItem("i",parseInt(count)+1);
        }else{
            var i = storage.setItem("i",2);
        }

        //日期控件
        $("#datetimepicker").datepicker({
            autoclose: true, //自动关闭
            beforeShowDay: $.noop,    //在显示日期之前调用的函数
            calendarWeeks: false,     //是否显示今年是第几周
            clearBtn: false,          //显示清除按钮
            daysOfWeekDisabled: [],   //星期几不可选
            endDate: Infinity,        //日历结束日期
            forceParse: true,         //是否强制转换不符合格式的字符串
            format: 'yyyy-mm-dd',     //日期格式
            keyboardNavigation: true, //是否显示箭头导航
            language: "zh-CN",           //语言
            minViewMode: 0,
            orientation: "auto",      //方向
            rtl: false,
            startDate: -Infinity,     //日历开始日期
            startView: 0,             //开始显示
            todayBtn: false,          //今天按钮
            todayHighlight: true,    //今天高亮
            weekStart: 0
        });


        //业务员赋值
        $("#email").click(function () {
            var value = $("#email :selected").val();
            if(value!="请选择"){
                $('#userName').val($('#email :selected').text());
            }
        });

        //保险公司赋值
        $("#select").click(function () {
            var value = $('#select :selected').val();
            if(value!="请选择"){
                $('#company').val($('#select :selected').text());
            }
        })

        $("#select-required").click(function () {
            var value3 = $('#select-required :selected').val();
            //if(value!='请选择'&&value3!='请选择'&&value!=''&&value3!=''&&value!=null&&value3!=null){
            if(value3!='请选择'&&value3!=''&&value3!=null){
                $("#ss").val(value3);
            }
        })
    });


    //分页展示
    var table1;
    var table2;
    function wrapTable1() {
        table1 = $("#modeltable").DataTable({
            "bAutoWidth": false,
            /*"order": [[0, 'desc']],*/
            ordering:false,
            "pagingType": "simple_numbers",//设置分页控件的模式
            searching: false,//屏蔽datatales的查询框
            aLengthMenu: [15],//设置一页展示10条记录
            "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表
            "oLanguage": {  //对表格国际化
                "sLengthMenu": "每页显示 _MENU_条",
                "sZeroRecords": "无匹配结果，请更换筛选条件再试",
                "sInfo": "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
                "sInfoEmpty": "当前第 0 - 0 条　共计 0 条",
                "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                "sSearch": "搜索：",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                }
            },
            "processing": true, //打开数据加载时的等待效果
            "serverSide": true,//打开后台分页
            "ajax": {
                "url": "/product/list",
                "dataSrc": "aaData",
                "data": function (params) {
                    var com = $('#companyId :selected').val();
                    if (com == '-1'){
                        params.companyId = null;
                    }else{
                        params.companyId = com;
                    }
                    var ty = $('#type :selected').val();
                    if(ty=='2'){
                        params.type = null;
                    }else{
                        params.type = ty;
                    }
                }
            },
            "columns": [
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var id = row.productId;
                        var tids = row.tid;
                        return "<a href='javascript:void(0);' onclick='toDetails("+tids+")'>"+id+"</a>";
                    }
                },
                {"data": "company",
                    "defaultContent": '--',
                    "bSortable": false
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.type=='0'){
                            status = "交强险";
                        }else if(row.type=='1'){
                            status = "商业险";
                        }
                        return status;
                    }
                },
                {
                    "data": "contractTime",
                    "defaultContent": '--',
                    "bSortable": false
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.separateStatus=='1'){
                            status = "是";
                        }else if(row.separateStatus=='2') {
                            status = "否";
                        }else{
                            status = "--";
                        }
                        return status;
                    }
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.modalityStatus=='1'){
                            status = "现金";
                        }else if(row.modalityStatus=='2'){
                            status = "三方开票";
                        }else{
                            status = "--";
                        }
                        return status;
                    }
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.useStatus=='0'){
                            if(row.checkStatus=='0'){
                                status = "设置定价中";
                            }else if(row.checkStatus=='1'){
                                status = "审核中";
                            }else if(row.checkStatus=='2'){
                                status = "审核驳回";
                            }
                        }else if(row.useStatus=='3'){
                            status= "已过期";
                        }
                        return status;
                    }
                }
            ],

            "columnDefs": [{
                "targets": 7,//是操作按钮目标列
                "data": null,
                "render": function (data, type, row) {
                    var ids = row.tid;
                    if(row.useStatus=='0'){
                        if(row.checkNode!=null){
                            if(row.checkNode==0){
                                if(row.checkStatus=='2'){

                                    return "<shiro:hasPermission name='product:setPoint'>" +
                                        "<a href='javascript:void(0);' onclick='updatePoint("+ids+",0)'>税点设置</a>" +
                                        "</shiro:hasPermission>" +
                                        "<shiro:hasPermission name='product:forPricing:delete'>" +
                                        "&nbsp;&nbsp;&nbsp;<a href='javascript:void(0);' onclick='openModel("+ids+",5)'>删除</a>"+
                                        "</shiro:hasPermission>";
                                    /*deleteById("+ids+")*/
                                }else{
                                     return "<shiro:hasPermission name='product:setPoint'>" +
                                     "<a href='javascript:void(0);' onclick='updatePoint("+ids+",0)'>税点设置</a>"+
                                     "</shiro:hasPermission>";

                                }
                            }else if(row.checkNode==1){
                                return "<shiro:hasPermission name='product:setRetentionPoint'>"+
                                    "<a href='javascript:void(0);' onclick='updateEaringPoint("+ids+",0)'>自留点位设置</a>"+
                                "</shiro:hasPermission>";
                            }else if(row.checkNode==3){
                                return "<shiro:hasPermission name='product:forPricing:employeeCheck'>"+
                                    "<a href='javascript:void(0);' onclick='toCheckPage("+ids+",0)'>审核</a>"+
                                    "</shiro:hasPermission>";
                            }else if(row.checkNode==4){
                                return "<shiro:hasPermission name='product:forPricing:managerCheck'>"+"" +
                                    "<a href='javascript:void(0);' onclick='toCheckPage("+ids+",1)'>审核</a>"+
                                    "</shiro:hasPermission>";
                            }
                        }
                    }else if(row.useStatus=='3'){
                        return null;
                    }


                }
            }]
        });

    }

    function wrapTable2() {
        table2 = $("#modeltable1").DataTable({
            "bAutoWidth": false,
           /* "order": [[0, 'desc']],*/
            ordering:false,
            "pagingType": "simple_numbers",//设置分页控件的模式
            searching: false,//屏蔽datatales的查询框
            aLengthMenu: [15],//设置一页展示10条记录
            "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表
            "oLanguage": {  //对表格国际化
                "sLengthMenu": "每页显示 _MENU_条",
                "sZeroRecords": "无匹配结果，请更换筛选条件再试",
                "sInfo": "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
                "sInfoEmpty": "当前第 0 - 0 条　共计 0 条",
                "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                "sSearch": "搜索：",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                }
            },
            "processing": true, //打开数据加载时的等待效果
            "serverSide": true,//打开后台分页
            "ajax": {
                "url": "/product/list",
                "dataSrc": "aaData",
                "data": function (params) {
                    var com = $('#companyId1 :selected').val();
                    if (com == '-1'){
                        params.companyId = null;
                    }else{
                        params.companyId = com;
                    }
                    var ty = $('#type1 :selected').val();
                    if(ty=='2'){
                        params.type = null;
                    }else{
                        params.type = ty;
                    }
                    var value = $('#useStatus :selected').val();
                    if(value=='2'){
                        params.useStatus = null;
                    }else{
                        params.useStatus = value;
                    }
                    params.t = 1;
                }
            },
            "columns": [
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var id = row.productId;
                        var tids = row.tid;
                        return "<a href='javascript:void(0);' onclick='toDetails("+tids+")'>"+id+"</a>";
                    }
                },
                {"data": "company",
                    "defaultContent": '--',
                    "bSortable": false
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.type=='0'){
                            status = "交强险";
                        }else if(row.type=='1'){
                            status = "商业险";
                        }
                        return status;
                    }
                },
                {
                    "data": "contractTime",
                    "defaultContent": '--',
                    "bSortable": false
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.separateStatus=='1'){
                            status = "是";
                        }else if(row.separateStatus=='2'){
                            status = "否";
                        }
                        return status;
                    }
                },
                {
                    "bSortable": false,
                    "defaultContent": '--',
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.modalityStatus=='1'){
                            status = "现金";
                        }else if(row.modalityStatus=='2'){
                            status = "三方开票";
                        }
                        return status;
                    }
                },
                {
                    "bSortable": false,
                    "render": function (data, type, row, meta) {
                        var status = "";
                        if(row.useStatus=='0'){
                            status = "已启用";
                        }else if(row.useStatus=='1'){
                            status = "已禁用";
                        }else if(row.useStatus=='3'){
                            status = "已过期";
                        }
                        return status;
                    }
                }
            ],

            "columnDefs": [{
                "targets": 7 ,//是操作按钮目标列
                "data": null,
                "render": function (data, type, row) {
                    var ids = row.tid;
                    if (row.useStatus == '0') {
                        return "<shiro:hasPermission name='product:setPoint'>" +
                            "<a href='javascript:void(0);' onclick='updatePoint(" + ids + ",1)'>税点设置</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "</shiro:hasPermission>" +
                            "<shiro:hasPermission name='product:setRetentionPoint'>" +
                            "<a href='javascript:void(0);' onclick='updateEaringPoint(" + ids + ",1)'>自留点位设置</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "</shiro:hasPermission>" +
                            "<shiro:hasPermission name='product:havePricing:disable'>" +
                            "<a href='javascript:void(0);' onclick='openModel(" + ids + ",1)'>禁用</a>" +
                            "</shiro:hasPermission>";
                        /*chageNotUse("+ids+",1)*/
                    } else if(row.useStatus == '1'){
                        return "<shiro:hasPermission name='product:havePricing:enable'>" +
                            "<a href='javascript:void(0);' onclick='openModel(" + ids + ",2)'>启用</a>" +
                            "</shiro:hasPermission>";
                        /*chageToUse("+ids+",0)*/
                    }else if(row.useStatus == '3'){
                        return null;
                    }

                }
            }]
        });

    }

    //删除
    function deleteById(tid) {
        /*if(confirm("确认删除此产品？")){
         }*/
        $.post(
            "/product/deleteById",
            {tid:tid},
            function (msg) {
                if (msg){
                    showRead();
                    //location = location;
                }
            },"json"
        );
    }

    //设置业务员
    function changeSalesman() {
        $('#email option').remove();
        $('#email').append("<option value=''>请选择</option>");
        var tid = $("#select :selected").val();
        $("#ts").val(tid);
        $.ajax({
            url:"/product/getSlaesmenByCompanyId",
            data:{tid:tid},
            type:"post",
            async:false,
            dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
            success:function(data){
                if(data!=null){
                    for (var i in data){
                        $("#email").append("<option value='"+data[i].userId+"'>"+data[i].userName+"</option>");
                    }
                }
            }
        })
        var messages = $('#select-required :selected').html();
        /*if(messages!='请选择'){
        }*/
        //$('#select-required').parsley().removeError('unique',{updateClass: true});
        $("#parsley-id-17").hide();
        $('#select-required').val('');
        $('#select-required').removeClass('parsley-error');
        $('#select-required').removeClass('parsley-success');
        $('#email').removeClass('parsley-success');
    }

    //税点设置
    function updatePoint(tid,type) {
        window.location.href = "/product/updatePoint?tid="+tid+"&m="+type;
    }

    //自留点位设置
    function updateEaringPoint(tid,type) {
        window.location.href = "/product/earingPoint?tid="+tid+"&m="+type;
    }

    //去审核页面
    function toCheckPage(tid,type) {
        window.location.href = "/product/check?tid="+tid+"&t="+type;
    }

    //详情页
    function toDetails(tid) {
        window.location.href = "/product/getDetails?tid="+tid;
    }

    //查询
    function search() {
        table1.ajax.reload();
    }
    function search1() {
        table2.ajax.reload();
    }

    //展示待定价
    function showRead() {
        table1.ajax.reload();

        $("#myTab li:eq(0)").addClass("active");
        $("#tab1").addClass("active in");
        $("#myTab li:eq(1)").removeClass("active");
        $("#myTab li:eq(2)").removeClass("active");
        $("#myTab li:eq(3)").removeClass("active");
        $("#myTab li:eq(3)").remove();
        $("#tab2").removeClass(" active in");
        $("#tab3").removeClass(" active in");
        $("#tab4").removeClass(" active in");
        $("#tab5").removeClass(" active in");
        $("#tab6").removeClass(" active in");
        $("#tab7").removeClass(" active in");
        $("#tab1").show();
    }

    // 展示已定价
    function showAlread() {
        table2.ajax.reload();

        $("#tab1").hide();
        $("#myTab li:eq(0)").removeClass("active");
        $("#myTab li:eq(2)").removeClass("active");
        $("#myTab li:eq(3)").removeClass("active");
        $("#myTab li:eq(3)").remove();
        $("#tab1").removeClass(" active in");
        $("#tab3").removeClass(" active in");
        $("#tab4").removeClass(" active in");
        $("#tab5").removeClass(" active in");
        $("#tab6").removeClass(" active in");
        $("#tab7").removeClass(" active in");
        $("#myTab li:eq(1)").addClass("active");
        $("#tab2").addClass(" active in")

    }

    //打开模态框
    function openModel(ids,type) {

        $("#tid").val(ids);
        $("#typee").val(type);
        if (type==1){
            $("#me").html("确认禁用该产品？");
        }else if(type==2){
            $("#me").html("确认解禁该产品？");

        }else if(type==3){
            $("#me").html("当前填写内容未提交，确认取消？");
        }else if(type==4){
            $("#me").html("该产品已存在");
        }else if(type==5){
            $("#me").html("确认删除此产品？");
        }else{

        }
        $('#modal-dialog').modal({backdrop: 'static', keyboard: false});
    }

    function doSomeThing() {
        var tid = $("#tid").val();
        var type = $("#typee").val();
        if (type==1){
            chageNotUse(tid);
        }else if(type==2){
            chageToUse(tid);
        }else if(type==3){
            window.location.href = "/product/toList";
        }else if(type==4){

        }else if(type==5){
            deleteById(tid);
        }else if(type==6){
            NoSure();
        }else if(type==7){
            Sure();
        }else{
            window.location.href="/product/toList";
        }
        $('#modal-dialog').modal('hide')
    }

    function openModel1(type) {
        var status = $("#myForm7").submit().parsley();
        if(status.isValid()){
            if(type==1){
                $("#typee").val(7);
                $("#me").html("确认审核通过？");
            }else if(type==2){
                $("#typee").val(6);
                $("#me").html("确认审核驳回？");
            }
            $('#modal-dialog').modal({backdrop: 'static', keyboard: false});
        }

    }
    //禁用
    function chageNotUse(tid) {
        /*if(confirm("确认禁用该产品？")){
         }*/
        $.post(
            "/product/useStatus",
            {tid:tid,status:1},
            function (msg) {
                if (msg){
                    showAlread();
                    //location = location;
                }
            },"json"
        );

    }
    //启用
    function chageToUse(tid) {
        /*if(confirm("确认解禁该产品？")){
         }*/
        $.post(
            "/product/useStatus",
            {tid:tid,status:0},
            function (msg) {
                if (msg){
                    showAlread();
                    //location = location;
                }
            },"json"
        );

    }

    function changeStatus(v) {
        $(v).attr('disable','disable');
    }

    //取消
    function cancle() {
        /*if(confirm("当前填写内容未提交，确认取消？")){
         //showRead();
         }*/
        window.location.href = "/product/toList";
    }


    //添加账期
    function addTime() {
        var storage=window.localStorage;
        var i = storage.getItem("i");
        var sourceNode = document.getElementById("add");
        var clonedNode = sourceNode.cloneNode(true);
        clonedNode.setAttribute('id','add'+i);
        var sourceNode1 = document.getElementById("appendDiv");
        sourceNode1.parentNode.appendChild(clonedNode);
        $("#add"+i+" input:eq(0)").attr('name','collectionForm['+i+'].paymentDays');
        $("#add"+i+" input:eq(1)").attr('name','collectionForm['+i+'].earnings');
        $("#add"+i+" label:eq(0)").html('&nbsp;');
        $("#add"+i).removeClass('hidden');
        i = parseInt(i)+1;

        storage.setItem("i",i);
    }

    function Sure() {
        /*if(confirm("确认审核通过？")){
         return true;
         }
         return false;*/
        var role = $("#role").val();
        var url = null;
        var url2 = null;
        if(role == '0'){
            url =  "/product/checkProductByEmployee";
            url2 = "/product/toList";
        }else if(role == '1'){
            url =  "/product/checkProductByManager";
            url2 = "/product/toList?m=1";
        }
        $.ajax({
            url: url,
            type: "POST",
            async:false,
            data: $('#myForm7').serialize(),
            success: function (data) {
                if (data) {
                    window.location.href = url2;

                }/* else {
                 $("#me").html("新建失败！");
                 openModel(null,8);
                 return false;
                 }*/
            }
        });
    }
    function NoSure() {
        /*if(confirm("确认审核驳回？")){
         }*/
        $.ajax({
            url: "/product/reject",
            type: "POST",
            async:false,
            data: $('#myForm7').serialize(),
            success: function (data) {
                if (data) {
                    window.location.href = "/product/toList";

                }/* else {
                 $("#me").html("新建失败！");
                 openModel(null,8);
                 return false;
                 }*/
            }
        });
    }

    //
    window.ParsleyValidator.addValidator('dateTime', function(value) {
        if(value!= ""){
            console.log("校验日期")
            return /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/.test(value);

        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('numbers', function(value) {
        if(value!= ""){
            console.log("校验成功")
            return /^[1-9]\d{0,2}$/.test(value);
        }
        return true;
    },32);

    /*window.Parsley
        .addValidator('point', {
            validateNumber: function(value, requirement) {
                return /^[1-9]\d{0,1}$/.test(value);
            },
            messages: {
                en: '数字格式不正确！'
            }
        });*/
    window.ParsleyValidator.addValidator('unique', function(value) {
        var value1 = $("#ts").val();
        var flag = true;
        var ww = $("#email").parsley();
        if(ww.isValid()){
            $('#email').addClass('parsley-success');
        }

        if(value1!='请选择'&&value!='请选择'&&value1!=''&&value!=''&&value1!=null&&value!=null){
            $.ajax({
                url:'/product/checkProduct',
                type:'POST', //GET
                async:false,    //或false,是否异步
                data:{
                    companyId:value1,type:value
                },
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                success:function(data){
                    if (data){
                        $("#parsley-id-17").show();
                        console.log("产品已存在")
                        flag = false;
                        //alert("该产品已存在");
                        //openModel(null,4);
                    }else{
                        console.log("产品不存在")
                    }
                }
            });
        }
        return flag;
    },32);
    //创建产品
    function createProduct() {
        var status = $('#myForm4').submit().parsley();
        if(status.isValid()){
            $("#sun").attr('disable','disable');
            $.ajax({
                url: "/product/insert",
                type: "POST",
                data: $('#myForm4').serialize(),
                //必须false才会自动加上正确的Content-Type
                //必须false才会避开jQuery对 formdata 的默认处理,XMLHttpRequest会对 formdata 进行正确的处理
                success: function (data) {
                    if (data) {
                        $("#me").html(data.msg);
                        openModel(null,8);

                    } else {
                        $("#me").html(data.msg);
                        openModel(null,8);
                        return false;
                    }
                }
            });
        }
    }
    //删除账期
    function deleteSeniorManagerDiv(v) {
        $(v).parent().parent().parent().remove();
    }
</script>
</body>
</html>
